package cn.swh.guguanjia.controller;

import cn.swh.guguanjia.entity.Demand;
import cn.swh.guguanjia.entity.Result;
import cn.swh.guguanjia.service.DemandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

//服务需求
@RestController
@RequestMapping("/mapper/demand")
public class DemandController {
    /**
     * @Description
     * @Params
     * @return
     **/

    @Autowired
    DemandService demandService;

    @RequestMapping("")
    public ModelAndView index(){
        return new ModelAndView("/demand/index.html");
    }

    //服务
    @RequestMapping("demandSelectPage/{pageNum}/{pageSize}")
    public Result demandSelectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize) {
        return new Result(demandService.demandSelectPage(pageNum, pageSize));
    }

    @RequestMapping(value = "/toDemand", method = RequestMethod.GET)
    public ModelAndView toDemand() {
        return new ModelAndView("/demand/detail.html");
    }

    @RequestMapping(value = "doDemand", method = RequestMethod.POST)
    public Result doDemand(@RequestBody Demand app) {
        return new Result(demandService.updateByPrimaryKeySelective(app));
    }



}
